package cn.itcast.service.role.impl;

import cn.itcast.dao.role.RoleDao;
import cn.itcast.domain.Role;
import cn.itcast.service.role.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImp implements RoleService {
    @Autowired
    private RoleDao roleDao;
    @Override
    public PageInfo findAllRole(int pageNum, int pageSize, String company_id) {
        PageHelper.startPage(pageNum,pageSize);
        List<Role> list=roleDao.findAllRole(company_id);
        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public void save(Role role) {
        roleDao.save(role);
    }

    @Override
    public Role findById(String id) {
        Role role = roleDao.findById(id);
        return role;
    }

    @Override
    public void update(Role role) {
    roleDao.update(role);
    }

    @Override
    public void delete(String id) {
        roleDao.delete(id);
    }

    @Override
    public List<Role> findRole(String company_id) {
        List<Role> allRole = roleDao.findAllRole(company_id);
        return allRole;
    }
    /*查询当前用户所对应得角色*/
    @Override
    public List<Role> findUserRole(String id) {
        List<Role> list=roleDao.findUserRole(id);
        return list;
    }

}
